﻿Ext.define('SmartClient.utils.CookieUtils',
   {
      statics:
         {
            getCookieValue: function(cookieName)
            {
               var name = cookieName + "=",
                  cookies = document.cookie.split(";");
               for (var i = 0; i < cookies.length; i++)
               {
                  var cookie = cookies[i].trim();
                  if (cookie.indexOf(name) == 0)
                  {
                     return cookie.substring(name.length, cookie.length);
                  }
               }
               return "";
            },

            setCookie: function(cookieName, cookieValue, expDays)
            {
               var currentDate = new Date();
               currentDate.setTime(currentDate.getTime() + (expDays * 24 * 60 * 60 * 1000));
               var expires = "expires=" + currentDate.toGMTString();
               document.cookie = cookieName + "=" + cookieValue + "; " + expires;
            },

            eraseCookie: function(cookieName)
            {
               SmartClient.utils.CookieUtils.setCookie(cookieName, "", -1);
            }
         }
   });